home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
c_lib.arc
/
FLCREATE.C
< prev
next >
Wrap
Text File
|
1990-08-09
|
3KB
|
80 lines
/**
*
* Name flcreate -- Create a file
*
* Synopsis ercode = flcreate(pfile,phandle,attrib);
* int ercode Returned DOS error code
* char *pfile File path name to be opened
* int *phandle Returned DOS file handle
* int attrib file attribute
*
* Description The specified file name is created if it does not exist,
* or truncates an existing file to zero length. The file
* is opened for reading and writing, and it can be accessed
* by using the returned handle number. Note that an
* existing read only file cannot be created (it cannot be
* truncated) nor can volume labels or subdirectories be
* created using FLCREATE. The possible file attributes are:
*
* 0 - General, no attribute
* 1 - Read only (may not be opened for writing)
* 2 - Hidden file
* 4 - System file
* 8 - Volumne label
* 16 - Subdirectory
* 32 - Archive flag (file changed since last backed up)
*
* File attributes may be combined by adding the attribute codes.
*
* Returns ercode DOS 2.0 function error code
* phandle File handle of the created file. If an
* error is encountered, -1 is returned.
*
* Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
*
**/
#include <compiler.h>
#define utbyword(a,b) (((a)<<8)|((b)&0x00ff)) /* a is high, b low */
struct dreg
{
unsigned ax,bx,cx,dx,si,di,ds,es;
};
#define DOSREG struct dreg
int flcreate(pfile,phandle,attrib)
char *pfile;
int *phandle,attrib;
{
DOSREG dos_reg;
int ercode,utinit(),dos();
#if CI201A & LDATA
unsigned long ptrtoabs();
#endif
utinit(&dos_reg); /* Initialize the registers */
dos_reg.ax = utbyword(0x3c,0); /* Function call 3C */
dos_reg.cx = utbyword(0,attrib);
#if LDATA
#if CI201A
dos_reg.ds = (unsigned)((ptrtoabs(pfile) & 0xffff0L) >> 4L);
dos_reg.dx = (unsigned)(ptrtoabs(pfile) & 0xfL);
#else
dos_reg.ds = (unsigned)(((long)(pfile) & 0xffff0L) >> 4L);
dos_reg.dx = (unsigned)((long)(pfile) & 0xfL);
#endif
#else
dos_reg.dx = (unsigned)pfile;
#endif
ercode = dos(&dos_reg);
if (ercode == 0)
*phandle = (int)dos_reg.ax;
else
*phandle = -1;
return(ercode);
}